<template>
  <el-dialog v-if="dialogVisible" title="视频列表" :visible.sync="dialogVisible" width="1200px">
    <div class="divBox">
      <div class="header clearfix">
        <div class="container">
          <el-form size="small" inline label-width="100px">
            <el-form-item label="视频标题：" class="width100">
              <el-input
                v-model="tableFrom.keyword"
                placeholder="请输入视频标题"
                class="selWidth"
                clearable
                @keyup.enter.native="getList"
              >
                <el-button slot="append" icon="el-icon-search" class="el-button-solt" @click="getList" />
              </el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <el-table v-loading="listLoading" :data="tableData.data" style="width: 100%;margin-top:10px;" size="mini">
        <el-table-column width="55">
          <template slot-scope="scope">
            <el-checkbox-group v-model="templateRadios" @change.native="getTemplateRow(scope.row)">
              <el-checkbox :label="scope.row.id">&nbsp</el-checkbox>
            </el-checkbox-group>
            <!-- <el-radio
              v-model="templateRadio"
              :label="scope.row.id"
              @change.native="getTemplateRow(scope.row)"
            >&nbsp</el-radio> -->
          </template>
        </el-table-column>
        <el-table-column prop="id" label="ID" min-width="50" />
        <el-table-column label="视频封面" min-width="80">
          <template slot-scope="scope">
            <div class="demo-image__preview">
              <el-image
                style="width: 36px; height: 36px"
                :src="scope.row.image_src"
                :preview-src-list="[scope.row.image_src]"
              />
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="title" label="视频标题" min-width="200" />
      </el-table>
      <div class="block mb20">
        <el-pagination
          :page-sizes="[20, 40, 60, 80]"
          :page-size="tableFrom.limit"
          :current-page="tableFrom.page"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
          @size-change="handleSizeChange"
          @current-change="pageChange"
        />
      </div>
    </div>
  </el-dialog>
</template>

<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
  getVideoList,
  delVideo,
  deitVideoStatus
} from "@/api/buss"
import { roterPre } from '@/settings'
export default {
  name: 'videoList',
  data() {
    return {
      dialogVisible: false,
      templateRadios: [],
      roterPre: roterPre,
      listLoading: true,
      tableData: {
        data: [],
        total: 0
      },
      tableFrom: {
        page: 1,
        limit: 20,
        keyword: '',
      },
      multipleSelection: {},
    }
  },
  props:['ids'],
  watch:{
    dialogVisible:function(){
      this.templateRadios = this.ids
    }
  },
  mounted() {
    this.getList()
    // this.templateRadio()
  },
  computed:{
  },
  methods: {
    templateRadio(){
      this.templateRadios = this.ids
    },
    getTemplateRow(row) {
      this.multipleSelection = row
      this.dialogVisible = false
      this.$emit('getProduct', this.multipleSelection)
    },
    // 列表
    getList() {
      this.listLoading = true
      getVideoList(this.tableFrom)
        .then((res) => {
          this.tableData.data = res.data.list
          this.tableData.total = res.data.count
          this.listLoading = false
        })
        .catch((res) => {
          this.listLoading = false
          this.$message.error(res.message)
        })
    },
    pageChange(page) {
      this.tableFrom.page = page
      this.getList()
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val
      this.getList()
    }
  }
}
</script>

<style scoped lang="scss">
.selWidth {
  width: 360px !important;
}
.seachTiele {
  line-height: 35px;
}
.fr {
  float: right;
}
</style>
